#!/bin/bash

DATE=$(date +%Y-%m-%d)
TIME=$(date +%Hh%M)
USTREAMER="/home/terrydr/ustreamer/ustreamer"
LOG="/home/pi/scripts/stream/ustreamer.log"


function help()
{
    echo "Usage: $0 [options]"
    echo "Options:"
    echo "  --1080p"
    echo "  --720p"
    echo "  --low"
    echo "  --help"
}

while [ $# -ge 1 ];do
    case "$1" in
        --1080p)
            RESOLUTION="1920x1080"
        ;;
        --720p)
            RESOLUTION="1280x720"
        ;;
        --low)
            RESOLUTION="640x480"
        ;;
        --fps)
            FRAMERATE="$2"
            shift
        ;;
        --help)
            help
            exit
        ;;
        *)
    esac
    shift
done

# Cleaning log file
echo -n> "$LOG"
# uncomment to use log
# exec &> >(tee -a "$LOG")

echo "$DATE - $TIME - Starting stream"

libcamerify "$USTREAMER" --host :: --encoder=m2m-VIDEO -r 1536x864 -n

exit